<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
use App\Common\Middleware\AdminMiddleware;
use App\Common\Middleware\PermissionGateMiddleware;
use Hyperf\HttpServer\Router\Router;

Router::addRoute(['GET', 'POST'], 'test', 'App\Controller\api\Auth@test');
Router::addRoute(['GET', 'POST'], 'login', 'App\Controller\api\Auth@login');
Router::addRoute(['POST'], 'logout', 'App\Controller\api\Auth@logout');
Router::addRoute(['GET'], 'download/{file}/{dir}/{filename}', 'App\Controller\api\File@download');

Router::addGroup('', function () {
    Router::addRoute(['GET'], 'options/{option}', 'App\Controller\api\Options@get');
    Router::addRoute(['GET'], 'user/login/log', 'App\Controller\api\permissions\Admin@loginLog');
    Router::addRoute(['GET'], 'user/operate/log', 'App\Controller\api\permissions\Admin@operateLog');
    Router::addRoute(['POST'], 'upload/image', 'App\Controller\api\Upload@image');
    Router::addRoute(['GET'],'excel', 'App\Controller\api\Generate@excel');


    Router::addRoute(['GET', 'POST'], 'user/online', 'App\Controller\api\permissions\Admin@online');
    Router::addRoute(['GET'], 'dashboard', 'App\Controller\api\Generate@dashboard');
    Router::addRoute(['GET'], 'permissions/roles', 'App\Controller\api\permissions\Roles@index');
    Router::addRoute(['GET'], 'permissions/roles/{id}', 'App\Controller\api\permissions\Roles@read');
    Router::addRoute(['POST'], 'permissions/roles', 'App\Controller\api\permissions\Roles@save');
    Router::addRoute(['DELETE'], 'permissions/roles/{id}', 'App\Controller\api\permissions\Roles@delete');
    Router::addRoute(['PUT'], 'permissions/roles/{id}', 'App\Controller\api\permissions\Roles@update');

    Router::addRoute(['GET'], 'permissions/permissions', 'App\Controller\api\permissions\Permissions@index');
    Router::addRoute(['POST'], 'permissions/permissions', 'App\Controller\api\permissions\Permissions@save');
    Router::addRoute(['PUT'], 'permissions/permissions/enable/{id}', 'App\Controller\api\permissions\Permissions@enable');
    Router::addRoute(['DELETE'], 'permissions/permissions/{id}', 'App\Controller\api\permissions\Permissions@delete');
    Router::addRoute(['GET'], 'permissions/permissions/{id}', 'App\Controller\api\permissions\Permissions@read');
    Router::addRoute(['PUT'], 'permissions/permissions/{id}', 'App\Controller\api\permissions\Permissions@update');

    Router::addRoute(['GET'], 'users', 'App\Controller\api\permissions\Users@index');
    Router::addRoute(['PUT'], 'users/enable/{id}', 'App\Controller\api\permissions\Users@enable');
    Router::addRoute(['GET'], 'users/{id}', 'App\Controller\api\permissions\Users@read');
    Router::addRoute(['DELETE'], 'users/{id}', 'App\Controller\api\permissions\Users@delete');
    Router::addRoute(['PUT'], 'users/{id}', 'App\Controller\api\permissions\Users@update');
    Router::addRoute(['POST'], 'users', 'App\Controller\api\permissions\Users@save');
    Router::addRoute(['GET'], 'user/export', 'App\Controller\api\permissions\Users@export');

    Router::addRoute(['GET'], 'permissions/departments', 'App\Controller\api\permissions\Departments@index');
    Router::addRoute(['POST'], 'permissions/departments', 'App\Controller\api\permissions\Departments@save');
    Router::addRoute(['PUT'], 'permissions/departments/enable/{id}', 'App\Controller\api\permissions\Departments@enable');
    Router::addRoute(['DELETE'], 'permissions/departments/{id}', 'App\Controller\api\permissions\Departments@delete');
    Router::addRoute(['GET'], 'permissions/departments/{id}', 'App\Controller\api\permissions\Departments@read');
    Router::addRoute(['PUT'], 'permissions/departments/{id}', 'App\Controller\api\permissions\Departments@update');

    Router::addRoute(['GET'], 'permissions/jobs', 'App\Controller\api\permissions\Jobs@index');
    Router::addRoute(['POST'], 'permissions/jobs', 'App\Controller\api\permissions\Jobs@save');
    Router::addRoute(['PUT'], 'permissions/jobs/enable/{id}', 'App\Controller\api\permissions\Jobs@enable');
    Router::addRoute(['DELETE'], 'permissions/jobs/{id}', 'App\Controller\api\permissions\Jobs@delete');
    Router::addRoute(['GET'], 'permissions/jobs/{id}', 'App\Controller\api\permissions\Jobs@read');
    Router::addRoute(['PUT'], 'permissions/jobs/{id}', 'App\Controller\api\permissions\Jobs@update');
}, [
    'middleware' => [
        AdminMiddleware::class,
        PermissionGateMiddleware::class,
    ],
]);
